using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class AddSpawnPointForm : Form
    {
        public event EventHandler AddSpawnPoint;

        public AddSpawnPointForm(Form _parent)
        {
            Owner = _parent;
            InitializeComponent();
            TileEditorForm _form = (TileEditorForm)_parent;
            for (int i = 0; i < _form.level.spawnPointsAvailable.Count; i++)
            {
                    List_SpawnTypes.Items.Add(_form.level.spawnPointsAvailable[i]);
            }
            List_SpawnTypes.SelectedIndex = 0;
            Show();
        }

        private void Checkbox_Infinite_CheckedChanged(object sender, EventArgs e)
        {
            NumberOfSpawns.Enabled = !(Checkbox_Infinite.Checked);
        }

        private void Button_AddSpawn_Click(object sender, EventArgs e)
        {
            if (AddSpawnPoint != null)
                AddSpawnPoint(this, new EventArgs());
            Close();
        }

        private void List_SpawnTypes_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool _enabled = (List_SpawnTypes.SelectedIndex >= 0 && (List_SpawnTypes.Items[List_SpawnTypes.SelectedIndex] as SpawnPoints).Type > (int)SpawnPoints.Characters.SURVIVOR_RESPAWN);
            NumberOfSpawns.Enabled = _enabled;
            Checkbox_Infinite.Enabled = _enabled;
            TimeBetweenSpawning.Enabled = _enabled;
            Checkbox_Infinite.Checked = false;
        }
    }
}